package operation.JiChen;

import java.awt.*;
import java.sql.SQLOutput;
import java.util.ArrayList;

public class Demo04Student {
    /*4. 分析以下需求，并用代码实现
	1.定义Student类
    属性:
    姓名：String name
    年龄：int age
    成绩：int score
    行为:
    空参构造方法
            有参构造方法
    set和get方法
	2.定义测试类,进行测试
            (1)创建5个学生对象存入ArrayList集合中
		(2)打印最高分的学员姓名、年龄、成绩  [要求封装1个方法  参数是集合对象   返回值类型为Student]
            (3)打印5个学生的总成绩和平均分		 [要求封装一个方法完成]
            (4)打印不及格的学员信息及数量		 [要求封装一个方法完成]*/
    public static void main(String[] args) {
        ArrayList<Student> list = new ArrayList<>();
        Student student1 = new Student("小明", 21, 56);
        Student student2 = new Student("小花", 19, 69);
        Student student3 = new Student("小兰", 24, 73);
        Student student4 = new Student("小红", 18, 57);
        Student student5 = new Student("小胖", 19, 92);
        list.add(student1);
        list.add(student2);
        list.add(student3);
        list.add(student4);
        list.add(student5);
        System.out.println(list);
        gei(list);
        gat(list);
        gcs(list);


    }

    private static void gcs(ArrayList<Student> d) {
        int c=0;
        for (Student student : d) {
            if(student.getScore()<=60){

            }
        }
        System.out.println(c);
    }

    private static void gat(ArrayList<Student> b) {
        int a=0;
        for (Student student : b) {
            if(student.getScore()<=60){
                a++;
            }
        }
        System.out.println(a);
    }

    Student s = new Student();

    private static void gei(ArrayList<Student> a) {
        int num = 0;

        for (Student s1 : a) {
            num += s1.getScore();
        }
        System.out.println(num);
    }
}
